class RenameThePolymorphicFields < ActiveRecord::Migration
  def self.up
    rename_column :user_favorite_infos, :relation_id, :favoritable_id
    rename_column :user_favorite_infos, :relation_type, :favoritable_type
    
    rename_column :user_abuse_reports, :relation_id, :abusable_id
    rename_column :user_abuse_reports, :relation_type, :abusable_type
    
    rename_column :item_recommends, :relation_id, :recommendable_id
    rename_column :item_recommends, :relation_type, :recommendable_type
    
    
    change_column :user_favorite_infos, :favoritable_id, :integer, :null => true
    change_column :user_abuse_reports, :abusable_id, :integer, :null => true
    change_column :item_recommends, :recommendable_id, :integer, :null => true
  end

  def self.down
    rename_column :user_favorite_infos, :favoritable_id, :relation_id
    rename_column :user_favorite_infos, :favoritable_type, :relation_type
    
    rename_column :user_abuse_reports, :abusable_id, :relation_id
    rename_column :user_abuse_reports, :abusable_type, :relation_type
    
    rename_column :item_recommends, :recommendable_id, :relation_id
    rename_column :item_recommends, :recommendable_type, :relation_type
  end
end
